fix(mcp): route web_search to Amazon Q endpoint with profile ARN for AWS SSO OIDC accounts - #237
fix(mcp): route web_search to Amazon Q endpoint with profile ARN for AWS SSO OIDC accounts#237yeeyon wants to merge 1 commit into
Conversation
…AWS SSO OIDC
web_search via the Kiro MCP endpoint fails for kiro-cli (AWS SSO OIDC)
accounts. Requests were sent to the runtime.{region}.kiro.dev host without
a profile ARN, which the endpoint rejects with 400 'profileArn is required'
and then 403 'not authorized'. This makes clients hang while retrying.
For AWS SSO OIDC accounts, route web_search to the Amazon Q endpoint
(https://q.{region}.amazonaws.com/mcp), pass the profile ARN via the
x-amzn-kiro-profile-arn header, and use the application/x-amz-json-1.0
content type. Region is derived from the profile ARN. Kiro Desktop auth
keeps the existing q_host behavior. The error log now includes the response
body so future MCP failures are not silent.
Adds unit tests covering endpoint/header selection for both auth types.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
Thanks for the PR! 🎉 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
|
I have read the CLA and I accept its terms |
|
@cla-bot check |
|
Thanks for the PR! 🎉 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
|
The cla-bot has been summoned, and re-checked this pull request! |
Problem
web_search(via the Kiro MCP endpoint) fails for kiro-cli / AWS SSO OIDC accounts.call_kiro_mcp_apisends the request tohttps://runtime.{region}.kiro.dev/mcp(theq_host) without a profile ARN. For AWS SSO OIDC accounts that endpoint rejects the call:400 Bad Request-profileArn is required403 Forbidden-User is not authorizedThe MCP call then returns
None, and clients (e.g. Claude Code) hang retrying the web_search tool. Kiro Desktop accounts are unaffected because their auth context resolves differently, which is why this is easy to miss.Root cause
For AWS SSO OIDC accounts the MCP
web_searchtool must be called on the Amazon Q endpoint, with the profile ARN supplied as a header (not in the body), and with thex-amz-json-1.0content type:https://runtime.{region}.kiro.dev/mcphttps://q.{region}.amazonaws.com/mcpx-amzn-kiro-profile-arnapplication/jsonapplication/x-amz-json-1.0Fix
AWS_SSO_OIDCauth with a profile ARN, routeweb_searchtohttps://q.{region}.amazonaws.com/mcp, sendx-amzn-kiro-profile-arn, and useapplication/x-amz-json-1.0. Region is derived from the profile ARN.q_hostbehavior (no change).Tests
Adds
TestMCPEndpointSelectionwith two cases:x-amzn-kiro-profile-arnheader +x-amz-json-1.0q_host, no profile-ARN headerpytest tests/unit/test_mcp_tools.py-> 23 passed.Verification
Verified end-to-end against a live kiro-cli (AWS SSO OIDC) account: native
web_searchnow streamsserver_tool_use->web_search_tool_result-> results, where it previously hung.